package cn.net.yugu.doraemon.sharding.config;

import cn.net.yugu.doraemon.sharding.interceptor.YgTableShardInterceptor;
import cn.net.yugu.doraemon.sharding.strategy.impl.DateTableShardStrategy;
import cn.net.yugu.doraemon.sharding.strategy.impl.HashedTableShardStrategy;
import cn.net.yugu.doraemon.sharding.strategy.impl.IdTableShardStrategy;
import cn.net.yugu.doraemon.sharding.utils.YgShardSpringBeanUtil;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wanghongli
 * @date 2023/12/16 15:14
 * @description TableShardingConfiguration
 **/
@Configuration
public class YgShardingAutoConfiguration {
    @Bean
    public DateTableShardStrategy dateTableShardStrategy() {
        return new DateTableShardStrategy();
    }

    @Bean
    public HashedTableShardStrategy hashedTableShardStrategy() {
        return new HashedTableShardStrategy();
    }

    @Bean
    public IdTableShardStrategy idTableShardStrategy() {
        return new IdTableShardStrategy();
    }

    @Bean
    public YgShardSpringBeanUtil ygShardSpringBeanUtil() {
        return new YgShardSpringBeanUtil();
    }

    @Bean(value = "ygTableShardInterceptor")
    public Interceptor tableShardInterceptor(){
        return new YgTableShardInterceptor();
    }
}
